<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			*{
				margin: 0;
				padding: 0;
			}
			.box{
				height: 150px;
				/* 水平居中 */
				text-align: center;
				padding-top: 50px;
				background-color: rgba(225,255,255,0.3);
			}
			img{
				width: 150px;
			}
			body{
				background-image: url(images/2.jpg);
			}
		</style>
	</head>
	<body>
		<div class="box">
			<img src="images/1.jpg" />
			<img src="images/2.jpg" />
			<img src="images/3.jpg" />
			<img src="images/4.jpg" />
			<img src="images/5.jpg" />
			
		</div>
		
		<script>
			$(document).ready(function(){
				var images = $("img")
				for(var i = 0;i <images.length;i++){
					
				}
			});
			
			window.onload = function(){
				var images = document.getElementsByTagName("img");
				for(var i = 0 ; i <images.length ; i++){
					images[i].onclick = function(){
						// this代表当前点击事件的对象image[i]
						var imageurl = this.src;
						console.log(imageurl);
						//document是大的DOM,其内的属性body的属性style的属性backgroudImage
						document.body.style.backgroundImage = "url("+imageurl+")";
					}
				}
 			}
		</script>
	</body>
</html>
